package service.client;

import java.rmi.RemoteException;

import business.BusinessFacade;
import business.client.interfaces.ClientMgt;
import client.entities.ClientVO;
import client.exceptions.BadClientException;
import client.exceptions.ClientNotHereException;
import client.exceptions.IncompleteClientException;
import client.exceptions.MissingClientException;
import client.interfaces.ClientRemoteMgt;
import dbExceptions.DataBaseErrorException;

public class ClientRemoteMgr implements ClientRemoteMgt {

	private static ClientRemoteMgr instance = null;

	private ClientRemoteMgr() {
	}

	public static ClientRemoteMgr getInstance() {
		if (instance == null)
			instance = new ClientRemoteMgr();
		return instance;
	}

	@Override
	public void addClient(ClientVO client) throws RemoteException, IncompleteClientException, MissingClientException, DataBaseErrorException, BadClientException {
		ClientMgt temp = BusinessFacade.getInstance().getClientMgt();
		temp.addClient(client);
	}

	@Override
	public ClientVO[] getClients() throws RemoteException {
		ClientMgt temp = BusinessFacade.getInstance().getClientMgt();
		return temp.getClients();
	}

	@Override
	public void updateClient(ClientVO client) throws RemoteException, IncompleteClientException, MissingClientException, BadClientException, DataBaseErrorException {
		ClientMgt temp = BusinessFacade.getInstance().getClientMgt();
		temp.updateClient(client);
	}

	@Override
	public void deleteClient(ClientVO client) throws RemoteException,
			MissingClientException, DataBaseErrorException, BadClientException {
		ClientMgt temp = BusinessFacade.getInstance().getClientMgt();
		temp.deleteClient(client);
	}

	@Override
	public ClientVO getClient(int ci) throws RemoteException, ClientNotHereException {
		ClientMgt temp = BusinessFacade.getInstance().getClientMgt();
		return temp.getClient(ci);
	}
}
